package cn.openea.perpartner.meily.web.entity.dto;

import cn.openea.perpartner.common.core.annotation.Excel;
import cn.openea.perpartner.meily.web.entity.Provider;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.function.Function;

/**
 * @author ysk
 * @version 1.0.1
 * @Description 区域服务商DTO
 * @createTime 2023年04月12日 10:35:00
 */
@Component
public class ProviderDTOFactory {

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @SuperBuilder
    public static class ExportDTO {
        @Excel(name = "平台Id")
        private String userId;
        @Excel(name = "服务商编号")
        private String providerId;
        @Excel(name = "是否绑定公众号")
        private String bindOfficialAccount;
        @Excel(name = "首单状态")
        private String firstOrderStatus;
        @Excel(name = "真实姓名")
        private String realName;
        @Excel(name = "昵称")
        private String nickName;
        @Excel(name = "手机号")
        private String phone;
        @Excel(name = "性别")
        private String sex;
        @Excel(name = "年龄层")
        private String age;
        @Excel(name = "所在地区")
        private String area;
        @Excel(name = "所在街道")
        private String street;
        @Excel(name = "店铺名")
        private String storeName;
        @Excel(name = "店铺类型")
        private String storeType;
        @Excel(name = "推荐人")
        private String referrer;
        @Excel(name = "创建时间")
        private String createTime;
    }

    public Function<Provider, ExportDTO> toExportDTO = (provider) -> {
        if (provider == null) {
            return null;
        }
        ExportDTO exportDTO = new ExportDTO();
        BeanUtils.copyProperties(provider, exportDTO);
        return exportDTO;
    };

}
